package com.example.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.Date;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class SysUser implements UserDetails {
    private Integer id;
    private String username;
    private String password;
    private String realname;
    
    // 是否过期
    private boolean isExpired;
    // 是否锁定
    private boolean isLocked;
    // 凭证是否有效
    private boolean isCredentials;
    // 是否启用
    private boolean isEnabled;
    
    private Date createTime;
    private Date loginTime;
    
    private List<GrantedAuthority> authorities;
    
    
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }
    
    @Override
    public String getPassword() {
        return password;
    }
    
    @Override
    public String getUsername() {
        return username;
    }
    
    @Override
    public boolean isAccountNonExpired() {
        return isExpired;
    }
    
    @Override
    public boolean isAccountNonLocked() {
        return isLocked;
    }
    
    @Override
    public boolean isCredentialsNonExpired() {
        return isCredentials;
    }
    
    @Override
    public boolean isEnabled() {
        return isEnabled;
    }
}
